#!/usr/bin/env python
# -*- coding: utf-8 -*-
#改脚本用于安装xtrabackup
import os
import sys
#检查软件是否已经安装
def Check():
        CheckCmd = "yum list installed | grep percona"
        retval = os.system(CheckCmd)
        if retval == 0 :
                print("已安装")
                exit()
        else:
                print("开始安装...")
#安装yum源
def Repo_Install():
        URL = 'https://repo.percona.com/yum/percona-release-latest.noarch.rpm'
        DownloadCmd = "yum install " +URL
        print(DownloadCmd)
        os.system(DownloadCmd)
#安装软件
def Server_Install():
        SERVER_NAME = 'percona-xtrabackup'
        InstallCmd = "yum install " + SERVER_NAME
        print(InstallCmd)
        os.system(InstallCmd)
if __name__ == '__main__':
        Check()
        Repo_Install()
        Server_Install()
